<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('我的项目')" />
</head>
<body class="gray-bg">

<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<div class="form-group">
    <div class="col-sm-12 search-collapse">
            <div class="row">
        <form id="formId">
            <div class="select-list">
                <ul>
                    <li>
                        <label>负责人：</label>
                        <input type="text" name="empName"/>
                    </li>

                    <li>
                        <label>状态：</label>
                        <select name="statusDatas" th:with="type=${@dict.getType('sys_project_status')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                    </li>

                    <li>
                        <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                        <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                    </li>
                </ul>
            </div>
        </form>
    </div>
    </div>

    </div>
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 white-bg" >
                <div class="btn-group-sm" id="toolbar" role="group">
                    <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="project:project:add">
                        <i class="fa fa-plus"></i> 添加项目
                    </a>
                </div>
                <div class="form-group" >
                    <div  class="table-responsive"  >
                        <div class="col-sm-12 select-table table-striped">
                            <table id="projectTableInfo" class="table table-condensed"></table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var sysUse = [[${@otherService.getSysUser()}]];
        var statusDatas = [[${@dict.getType('sys_project_status')}]];
        var prefix = ctx + "project/project";


        $(function() {

            var options = {
                id: "projectTableInfo",
                url: prefix + "/projectTableInfo",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                modalName: "项目",
                columns: [
                    {
                        field: 'id',
                        title: '项目id',
                        visible: false
                    },
                    {
                        field: 'name',
                        title: '项目名称'
                    },
                    {
                        field: 'contentDescribe',
                        title: '描述'
                    },
                    {
                        field: 'empId',
                        title: '负责人Id',
                        visible: false,
                        formatter: function(value, row, index) {

                            return value;
                        }
                    },
                    {
                        field: 'empName',
                        title: '负责人',
                        formatter: function(value, row, index) {
                            return value;
                        }
                    },
                    {
                        field: 'status',
                        title: '状态',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(statusDatas, value);
                        }
                    },
                    {
                        field: 'createId',
                        title: '创建者id',
                        visible: false
                    },
                    {
                        field: 'createTime',
                        title: '创建时间'
                    },
                    {
                        field: 'updateId',
                        title: '更新者id',
                        visible: false
                    },
                    {
                        field: 'remark',
                        title: '备注',
                        visible: false
                    },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function(value, row, index) {
                            let projectId = row.id;
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="openHtml(\''+'项目成员'+'\',\''+'/project/projectEmp/projectEmpInfo?type=0&projectId=' + projectId+'\')"><i class="fa fa-edit"></i>成员</a> ');
                            // actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="openHtml(\''+'项目迭代'+'\',\''+'/project/projectPlan/projectPlanInfo?type=1&projectId=' + projectId+'\')"><i class="fa fa-edit"></i>项目迭代</a> ');
                            // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');

                            if ( sysUse.userId == row.empId || sysUse.loginName == 'admin' ) {
                                // if (row.status == 0){
                                    actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                                    /*if (sysUse.userId == row.empId){
                                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="finishProject(\'' + row.id + '\')"><i class="fa fa-edit"></i>完成</a> ');
                                    }*/
                                // }
                            }

                            return actions.join('');
                        }
                    }]
            };
            $.table.init(options);
        });

        function openHtml(title,url) {
            $.modal.openMain(title , url,($(window).width() - 20),($(window).height() - 20),null,1);
        }

/*        function finishProject(id) {
            $.modal.confirm("确定完成了吗?", function() {
                $.operate.submit(prefix + "/finishProject?id="+id);
            });
        }*/

    </script>
</body>
</html>